package com.hualan.servlet;
import com.alibaba.fastjson.JSON;
import com.hualan.dao.ShopGoodsDao;
import com.hualan.dao.impl.ShopGoodsDaoImpl;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;


@WebServlet("/status")
public class StatusList extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);
    }
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        ShopGoodsDao goodsDao = new ShopGoodsDaoImpl();
        String i =request.getParameter("goods_status");
        try {
            response.setContentType("text/html;charset=utf-8");
            response.setCharacterEncoding("utf-8");
            Map<String,Object> map = new HashMap<>();
            map.put("list", goodsDao.statuslist(i));
            String json = JSON.toJSONString(map);
            response.getWriter().write(json);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

    }
}
